#!/usr/bin/python3
# -*- coding:utf-8 -*-
# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================

import os
import numpy as np

def gen_golden_data_atan2():
    """Generate golden data for atan2 operation (arctangent of y/x with quadrant correction)"""
    dtype = np.float32
    input_shape = [8, 2048]
    output_shape = [8, 2048]

    # 生成输入数据：x和y坐标，包含正负数以覆盖所有象限
    x = np.random.uniform(-10, 10, input_shape).astype(dtype)
    y = np.random.uniform(-10, 10, input_shape).astype(dtype)

    # 使用numpy的arctan2计算带象限的反正切，结果范围[-π, π]
    golden = np.arctan2(y, x).astype(dtype)

    # 创建目录并保存文件
    os.system("mkdir -p input")
    os.system("mkdir -p output")
    x.tofile("./input/input_x.bin")
    y.tofile("./input/input_y.bin")
    golden.tofile("./output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_atan2()